/**
 * 2进制-->10进制  binary2dec.js 这段代码还有问题
 */
function binary2dec(binary) {
    c = binary.split("");//内存里切成字符串
    dec = 0;
    for (i = 0; i < c.length; i++) {
        temp = 1;
        //从第12位开始等于1
        if (c[i] == 1) {
            for (j = i + 1; j < c.length; j++) temp *= 2;
            //累加
            dec += temp;
        } else if (c[i] != 0) {
            console.log("不是二进制!");
            return false;
        }
    }
        return dec;
}

var binary="0000000000101001 "
console.log(binary2dec(binary))  //41 但计算出来是82 ...